package main

import (
	"bytes"
	"encoding/json"
)

type param struct {
	IsArray   bool     `yaml:isarray`
	Url       string   `yaml:url`
	Json      string   `yaml:json`
	Position  []string `yaml:position`
	UrlMethod string   `yaml:urlmethod`
}

type Requestbody struct {
	req []byte
}

func (r *Requestbody) Json2map() (s []map[string]interface{}, err error) {
	var result []map[string]interface{}
	r.req = bytes.TrimPrefix(r.req, []byte("\xef\xbb\xbf"))
	if err := json.Unmarshal([]byte(r.req), &result); err != nil {
		return nil, err
	}
	return result, nil
}
func (r *Requestbody) Json2maps() (s map[string]interface{}, err error) {
	var result map[string]interface{}
	r.req = bytes.TrimPrefix(r.req, []byte("\xef\xbb\xbf"))
	if err := json.Unmarshal([]byte(r.req), &result); err != nil {
		return nil, err
	}
	return result, nil
}
